-module(testES1).
-include_lib("event_model.hrl").
-export([run/0]).

run() ->
  Main = self(),
  G = spawn(fun()->event_generator:init(Main,8000,[200000], [1],[[1,2]]) end),
  receive
    _->
      ok
  end,
  Routers = get_routers(),
  %io:format("Routers:~p~n",[Routers]),
  R = spawn(fun()->router_manager:init(Routers) end),
  M = spawn(fun()->event_manager:init(Main, R, G, "ES1") end),
  receive
    finish ->
      finish
  end.

get_routers()->
  R2 = #router{id=2},
  Buffers = dict:new(),
  Buffer=#buffer{dest_id=2,k=10,rate=1.25*8000},
  NewBuffers = dict:store(2,Buffer, Buffers),
  R1 = #router{id=1, buffers=NewBuffers},
  Routers = dict:new(),
  NewRouters = dict:store(1, R1, Routers),
  dict:store(2, R2, NewRouters).
